	function requestWeather(lat, lon)
	{
		try
		{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		}
		catch (e)
		{
			alert("Permission UniversalBrowserRead denied.");
		}

		var http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
		if (!http_request)
		{
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.open('GET', 'http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=' + lat + ',' + lon, false);
		http_request.setRequestHeader('Cache-Control','no-cache')
		http_request.send(null);

		var airport = null;
		var pws = null;
		var zip = null;
		var radar = null;
		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{
				airport = http_request.responseXML.getElementsByTagName('airport')[0].getElementsByTagName('icao')[0].textContent;
				pws = http_request.responseXML.getElementsByTagName('pws')[0].getElementsByTagName('id')[0].textContent;
				zip = http_request.responseXML.getElementsByTagName('zip')[0].textContent;
				radar = http_request.responseXML.getElementsByTagName('image_url')[0].textContent;
			}
			else
			{
				alert('There was a problem with the request.');
				return;
			}
		}


		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
		if (!http_request)
		{
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.open('GET', 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=' + pws, false);
		http_request.setRequestHeader('Cache-Control','no-cache')
		http_request.send(null);

		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{
				var weatherLocation = document.getElementById('weatherLocation');
				if (weatherLocation.firstChild == null)
				{
					var textNode = document.createTextNode("temp");
					weatherLocation.appendChild(textNode);
				}
				weatherLocation.firstChild.nodeValue = http_request.responseXML.getElementsByTagName('location')[0].getElementsByTagName('city')[0].textContent;

				var weatherTemperature = document.getElementById('weatherTemperature');
				if (weatherTemperature.firstChild == null)
				{
					var textNode = document.createTextNode("temp");
					weatherTemperature.appendChild(textNode);
				}
				weatherTemperature.firstChild.nodeValue = http_request.responseXML.getElementsByTagName('temperature_string')[0].textContent;
			}
		}


		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
		if (!http_request)
		{
			alert('Cannot create XMLHTTP instance');
			return false;
		}

		now = new Date();
		var nowText = now.format('Y-m-d') + 'T00%3A00%3A00';
		tomorrow = new Date(now.getYear() + 1900, now.getMonth(), now.getDate(), now.getHours() + 18, now.getMinutes(), now.getSeconds());
		var tomorrowText = tomorrow.format('Y-m-d') + 'T' + tomorrow.format('H') + '%3A' + tomorrow.format('i') + '%3A' + tomorrow.format('s');
		var path = 'http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLclient.php?whichClient=NDFDgen&lat=' + lat + '&lon=' + lon + '&product=time-series&begin=' + nowText + '&end=' + tomorrowText + '&temp=temp&icons=icons&Submit=Submit'
		http_request.open('GET', path, false);
		http_request.setRequestHeader('Cache-Control','no-cache')
		http_request.send(null);

		var hourlyTemps;
		var hourlyIcons;
		var hourlyTimes;
		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{
				hourlyTimes = http_request.responseXML.getElementsByTagName('start-valid-time');
				hourlyTemps = http_request.responseXML.getElementsByTagName('temperature')[0].getElementsByTagName('value');
				hourlyIcons = http_request.responseXML.getElementsByTagName('conditions-icon')[0];
			}
		}


		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
		if (!http_request)
		{
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.open('GET', 'http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=' + airport, false);
		http_request.setRequestHeader('Cache-Control','no-cache')
		http_request.send(null);

		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{
				var weatherCondition = document.getElementById('weatherCondition');
				if (weatherCondition.firstChild == null)
				{
					var textNode = document.createTextNode("temp");
					weatherCondition.appendChild(textNode);
				}
				weatherCondition.firstChild.nodeValue = http_request.responseXML.getElementsByTagName('weather')[0].textContent;
			}
			else
			{
				alert('There was a problem with the request.');
			}
		}

		findWeatherIcon(weatherCondition.firstChild.nodeValue, true, document.getElementById('currentWeatherImage'), 110, 165, 125, 125);

		var im = document.getElementById('radarImage');
		var node = document.createElementNS(svgNS,"image");
		node.setAttributeNS(svgNS,"x",480);
		node.setAttributeNS(svgNS,"y",300);
		node.setAttributeNS(svgNS,"width",300);
		node.setAttributeNS(svgNS,"height",300);
		node.setAttributeNS(svgNS, "xlink:href","weather.gif");
		if (im.firstChild == null)
		{
			im.appendChild(node);
		}
		else
		{
			im.firstChild.nodeValue = node;
		}

		icons = document.getElementById('hourlyForcast');
		for (i = 0; i < ((hourlyTimes.length > 3) ? 3 : hourlyTimes.length); i++)
		{
			var icon = document.createElementNS(svgNS,"g");
			if (hourlyIcons.getElementsByTagName('icon-link')[i].firstChild.nodeValue != null)
			{
				var type = hourlyIcons.getElementsByTagName('icon-link')[i].firstChild.nodeValue.substring(hourlyIcons.getElementsByTagName('icon-link')[i].firstChild.nodeValue.indexOf('/wtf/') + 5);
				findWeatherIcon(decodeNDFDData(type), true, icon, 280 + (i * 55), 100, 40, 40);
				icons.appendChild(icon);
			}

			if (hourlyTimes[i].firstChild != null)
			{
				var node = document.createElementNS(svgNS,"text");
				node.setAttributeNS(null,"x",280 + (i * 55));
				node.setAttributeNS(null,"y",155);
				node.setAttributeNS(null,"font-family","Verdana");
				node.setAttributeNS(null,"font-size",13);
				node.setAttributeNS(null,"fill","#ffffff");
//				node.setAttributeNS(null,"style","dominant-baseline: central;text-anchor: middle;");
				var t = hourlyTimes[i].firstChild.nodeValue.substring(11,13);
				if (t > 12)
				{
					var textNode = document.createTextNode((t - 12) + ' PM');
					node.appendChild(textNode);
				}
				else
				{
					var textNode = document.createTextNode(t + ' AM');
					node.appendChild(textNode);
				}
				icon.appendChild(node);
			}

			if (hourlyTemps[i].firstChild != null)
			{
				var node = document.createElementNS(svgNS,"text");
				node.setAttributeNS(null,"x",280 + (i * 55));
				node.setAttributeNS(null,"y",169);
				node.setAttributeNS(null,"font-family","Verdana");
				node.setAttributeNS(null,"font-size",13);
				node.setAttributeNS(null,"fill","#ffffff");
//				node.setAttributeNS(null,"style","dominant-baseline: central;text-anchor: middle;");
				var textNode = document.createTextNode(hourlyTemps[i].firstChild.nodeValue + ' F');
				node.appendChild(textNode);
				icon.appendChild(node);

			}

			icons.appendChild(icon);
		}

		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
		if (!http_request)
		{
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.open('GET', 'http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=' + zip, false);
		http_request.setRequestHeader('Cache-Control','no-cache')
		http_request.send(null);

		var dailyForcasts = null;
		if (http_request.readyState == 4)
		{
			if (http_request.status == 200)
			{
				dailyForcasts = http_request.responseXML.getElementsByTagName('simpleforecast')[0].getElementsByTagName('forecastday');
			}
			else
			{
				alert('There was a problem with the request.');
			}
		}
		
		icons = document.getElementById('dailyForcast');
		for (i = 0; i < ((dailyForcasts.length > 3) ? 3 : dailyForcasts.length); i++)
		{
			var icon = document.createElementNS(svgNS,"g");
			var dayIcon = dailyForcasts[i].getElementsByTagName('conditions')[0].textContent;
			var dayHigh = dailyForcasts[i].getElementsByTagName('high')[0].getElementsByTagName('fahrenheit')[0].textContent;
			var dayLow = dailyForcasts[i].getElementsByTagName('low')[0].getElementsByTagName('fahrenheit')[0].textContent;
			var dayName = dailyForcasts[i].getElementsByTagName('date')[0].getElementsByTagName('weekday')[0].textContent;
			
			if (dayIcon != null)
			{
				findWeatherIcon(dayIcon, i == 0, icon, 125 + (i * 95), 300, 60, 60);
				icons.appendChild(icon);
			}

			if (dayName != null)
			{
				var node = document.createElementNS(svgNS,"text");
				node.setAttributeNS(null,"x",125 + (i * 95));
				node.setAttributeNS(null,"y",290);
				node.setAttributeNS(null,"font-family","Verdana");
				node.setAttributeNS(null,"font-size",13);
				node.setAttributeNS(null,"fill","#ffffff");
//				node.setAttributeNS(null,"style","dominant-baseline: central;text-anchor: middle;");
				var textNode = document.createTextNode(dayName);
				node.appendChild(textNode);
				icon.appendChild(node);
			}

			if (dayHigh != null)
			{
				var node = document.createElementNS(svgNS,"text");
				node.setAttributeNS(null,"x",125 + (i * 95));
				node.setAttributeNS(null,"y",385);
				node.setAttributeNS(null,"font-family","Verdana");
				node.setAttributeNS(null,"font-size",13);
				node.setAttributeNS(null,"fill","#ffffff");
//				node.setAttributeNS(null,"style","dominant-baseline: central;text-anchor: middle;");
				var textNode = document.createTextNode(dayHigh + ' F');
				node.appendChild(textNode);
				icon.appendChild(node);
			}

			if (dayLow != null)
			{
				var node = document.createElementNS(svgNS,"text");
				node.setAttributeNS(null,"x",125 + (i * 95));
				node.setAttributeNS(null,"y",400);
				node.setAttributeNS(null,"font-family","Verdana");
				node.setAttributeNS(null,"font-size",13);
				node.setAttributeNS(null,"fill","#ffffff");
//				node.setAttributeNS(null,"style","dominant-baseline: central;text-anchor: middle;");
				var textNode = document.createTextNode(dayLow + ' F');
				node.appendChild(textNode);
				icon.appendChild(node);
			}

			icons.appendChild(icon);
		}
	}
	
	
	function decodeNDFDData(icon)
	{
		var retVal = '';
		
		if (icon.charAt(0) == 'n')
		{
			icon = icon.substring(1);
		}
		
		switch (icon)
		{
			case 'sct.jpg':
				retVal = 'partly cloudy';
			break;
			
			case 'bkn.jpg':
				retVal = 'mostly cloudy';
			break;
			
			case 'ra10.jpg':
			case 'ra20.jpg':
			case 'ra30.jpg':
			case 'ra40.jpg':
			case 'ra50.jpg':
			case 'ra60.jpg':
			case 'ra70.jpg':
			case 'ra80.jpg':
			case 'ra90.jpg':
			case 'ra100.jpg':
			case 'shra10.jpg':
			case 'shra20.jpg':
			case 'shra30.jpg':
			case 'shra40.jpg':
			case 'shra50.jpg':
			case 'shra60.jpg':
			case 'shra70.jpg':
			case 'shra80.jpg':
			case 'shra90.jpg':
			case 'shra100.jpg':
				retVal = 'drizzle';
			break;
			
			case 'tsra10.jpg':
			case 'tsra20.jpg':
			case 'tsra30.jpg':
			case 'tsra40.jpg':
			case 'tsra50.jpg':
			case 'tsra60.jpg':
			case 'tsra70.jpg':
			case 'tsra80.jpg':
			case 'tsra90.jpg':
			case 'tsra100.jpg':
				retVal = 'thunderstorms';
			break;
			
			case 'ovc.jpg':
				retVal = 'overcast';
			break;
			
			default:
				alert('decode -> ' + icon);
			break;
		}
		
		return retVal;
	}

	function findWeatherIcon(condition, useTime, img, x, y, w, h)
	{
		var tempIcon = 'weather/';
		var currTime = new Date();
		var hours = currTime.getHours();
		if ((useTime) && ((hours < 6) || (hours > 18)))
		{
			switch (condition.toLowerCase())
			{
				case 'clear':
					tempIcon += 'clear-night.svgz';
				break;

				case 'overcast':
					tempIcon += 'mostly-cloudy-night.svgz';
				break;

				case 'partly cloudy':
					tempIcon += 'partly-cloudy-night.svgz';
				break;

				case 'mostly cloudy':
					tempIcon += 'mostly-cloudy-night.svgz';
				break;

				case 'thunderstorms':
				case 'thunderstorm':
				case 'chance of a thunderstorm':
					tempIcon += 'thunderstorms.svgz';
				break;

				case 'drizzle':
				case 'light rain mist':
				case 'light rain':
					tempIcon += 'drizzle.svgz';
				break;

				case 'rain':
				case 'rain showers':
					tempIcon += 'showers.svgz';
				break;
			}
		}
		else
		{
			switch (condition.toLowerCase())
			{
				case 'clear':
					tempIcon += 'fair-day.svgz';
				break;
				
				case 'overcast':
					tempIcon += 'mostly-cloudy-day.svgz';
				break;

				case 'partly cloudy':
					tempIcon += 'partly-cloudy-day.svgz';
				break;

				case 'mostly cloudy':
					tempIcon += 'mostly-cloudy-day.svgz';
				break;

				case 'thunderstorms':
				case 'thunderstorm':
				case 'chance of a thunderstorm':
					tempIcon += 'thunderstorms.svgz';
				break;

				case 'drizzle':
				case 'light rain mist':
				case 'light rain':
				case 'rain':
					tempIcon += 'drizzle.svgz';
				break;

				case 'rain':
				case 'rain showers':
					tempIcon += 'showers.svgz';
				break;
			}
		}

		if (tempIcon != 'weather/')
		{
			var xmlDoc = document.implementation.createDocument("","doc",null);
			xmlDoc.async = false;
			xmlDoc.load(tempIcon);
			var icon = document.createElementNS(svgNS,"g");
			icon.appendChild(xmlDoc.documentElement);

			if (img.firstChild != null)
			{
				img.replaceChild(icon, img.firstChild);
			}
			else
			{
				img.appendChild(icon);
			}
			var tempW = w / icon.firstChild.getAttribute("width");
			var tempH = h / icon.firstChild.getAttribute("height");
			var temp = "translate(" + x + "," + y + ") scale(" +tempW + ", " + tempH + ")"
			icon.setAttribute("transform", temp);
		}
		else
		{
			alert(condition);
		}
	}